home *** CD-ROM | disk | FTP | other *** search
- { msgicons.pas -- Display stock icons in message boxes }
-
- program MsgIcons;
-
- {$R msgicons.res}
-
- uses WinTypes, WinProcs, WObjects, Strings;
-
- const
-
- id_Menu = 100; { Menu resource ID }
-
- cm_Asterisk = 101; { Menu-command IDs }
- cm_Exclamation = 102;
- cm_Hand = 103;
- cm_Information = 104;
- cm_Question = 105;
- cm_Stop = 106;
-
- type
-
- MsgApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- PMsgWindow = ^MsgWindow;
- MsgWindow = object(TWindow)
- constructor Init(AParent: PWindowsObject; ATitle: PChar);
- procedure ShowMsg(P: PChar; MbType: Word);
- procedure WMCommand(var Msg: TMessage);
- virtual wm_First + wm_Command;
- end;
-
-
- { MsgApplication }
-
- {- Initialize MsgApplication object's window }
- procedure MsgApplication.InitMainWindow;
- begin
- MainWindow := New(PMsgWindow, Init(nil, 'Msg'))
- end;
-
-
- { MsgWindow }
-
- {- Construct MsgWindow object }
- constructor MsgWindow.Init(AParent: PWindowsObject; ATitle: PChar);
- begin
- TWindow.Init(AParent, ATitle);
- Attr.Menu := LoadMenu(HInstance, PChar(id_Menu))
- end;
-
- {- Display selected message box with icon }
- procedure MsgWindow.ShowMsg(P: PChar; MbType: Word);
- var
- D: array[0 .. 35] of Char;
- begin
- StrCopy(D, 'Message type = ');
- StrCat(D, P);
- MessageBox(HWindow, D, 'Message Box with Icon', MbType)
- end;
-
- {- Intercept all wm_Command messages }
- procedure MsgWindow.WMCommand(var Msg: TMessage);
- begin
- case Msg.WParam of
- cm_Asterisk:
- ShowMsg('mb_IconAsterisk', mb_IconAsterisk);
- cm_Exclamation:
- ShowMsg('mb_IconExclamation', mb_IconExclamation);
- cm_Hand:
- ShowMsg('mb_IconHand', mb_IconHand);
- cm_Information:
- ShowMsg('mb_IconInformation', mb_IconInformation);
- cm_Question:
- ShowMsg('mb_IconQuestion', mb_IconQuestion);
- cm_Stop:
- ShowMsg('mb_IconStop', mb_IconStop);
- else
- TWindow.WMCommand(Msg)
- end
- end;
-
- var
-
- MsgApp: MsgApplication;
-
- begin
- MsgApp.Init('MsgApp');
- MsgApp.Run;
- MsgApp.Done
- end.
-
-
- {--------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 3/07/1991
- ---------------------------------------------------------------}
-